#ifndef SPEEDPROFILEWIDGET_H
#define SPEEDPROFILEWIDGET_H

#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QTimer>

class SpeedProfileWidget : public QWidget
{
    Q_OBJECT
public:
    explicit SpeedProfileWidget(QWidget *parent = 0);
    void setAxisNames(QString verticalName, QString horizontalName);
    void setAxisRanges(qreal vMin, qreal vMax, qreal hMin, qreal hMax);
    void addPoint(QPointF *dataPoint);
    void reset();

signals:
    void mouseOver(qreal horizontalValue);

public slots:
    void pretendMouseOver(qreal horizontalValue);

protected:
    void paintEvent(QPaintEvent *event);
    void mouseMoveEvent(QMouseEvent* event);

private:
    QString vAxisName;
    QString hAxisName;
    qreal vAxisMin, vAxisMax;
    qreal hAxisMin, hAxisMax;
    bool mouseIsOver;
    QList<QPointF*> dataPoints;
    QTimer* updateTimer;

    void drawAxises(QPainter* p);
    void drawProfile(QPainter* p);
};

#endif // SPEEDPROFILEWIDGET_H
